package com.example.myapplication.ViewModel

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Face
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.lifecycle.ViewModel
import com.example.myapplication.model.entity.Category
import com.example.myapplication.model.entity.DataType
import com.example.myapplication.model.entity.SwiperData

class MainViewModel : ViewModel() {

    // 分类数据
    var categories by mutableStateOf(
        listOf(
            Category("思想政治"),
            Category("法律法规"),
            Category("职业道德"),
            Category("诚信自律")
        )
    )

    // 当前选中tab下标, 防止外部直接操作,需要将set方法设为私有,在页调用方法修改
    var categoryIndex by mutableStateOf(0)
        private set

    // 修改下标
    fun updateCategoryIndex(index: Int) {
        categoryIndex = index
    }

    // 类型数据
    var types by mutableStateOf(
        listOf(
            DataType("相关资讯", Icons.Default.Face),
            DataType("视频课程", Icons.Default.Email)
        )
    )

    // 当前选中类型下标
    var typeIndex by mutableStateOf(0)
        private set

    // 是否显示文章列表
    var showArticle: Boolean by mutableStateOf(true)
        private set

    // 更新当前使用下标
    fun updateTypeIndex(index: Int) {
        typeIndex = index
        showArticle = typeIndex === 0
    }

    // 轮播图数据
    val swiperList = listOf(
        SwiperData("https://img2.baidu.com/it/u=1052506207,4234602774&fm=253&fmt=auto&app=138&f=JPEG?w=752&h=500"),
        SwiperData("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fstatic.hdw.eweb4.com%2Fmedia%2Fwallpapers_dl%2F1%2F119%2F1189669-apple.jpg&refer=http%3A%2F%2Fstatic.hdw.eweb4.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1658645607&t=dee1e26bc578597dfbbbb7e946ce899c"),
        SwiperData("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fphoto%2F2011-10-22%2Fenterdesk.com-B410139D6A954D4E7A311661CDA8A405.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1658645607&t=cf721b9f2ded277e4a69cd22b7b431e8"),
        SwiperData("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.99it.com.cn%2Fuploads%2Fallimg%2F211218%2F1111462U6-0.jpg&refer=http%3A%2F%2Fwww.99it.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1658645607&t=d0252f4181336b55039b618c6669b4a7"),
        SwiperData("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpapers.co%2Fwallpaper%2Fpapers.co-al57-logo-art-apple-rainbow-minimal-24-wallpaper.jpg&refer=http%3A%2F%2Fpapers.co&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1658645607&t=287151fe1f926945a40aeaccf6b29a4a"),
    )

    // 通知数据
    val notifications = listOf<String>("薇娅丈夫公司违反广告法被罚19万", "刘畊宏说周杰伦留给他的歌不多了刘畊宏说周杰伦留给他的歌不多了", "香港回归25年来那些珍贵的首次", "男生卖力宣传母校被吐槽是招生减章")
}